#include "SparkEditorMenuFile.h"
#include "SparkEditorResource.h"
#include "SparkEditorFrame.h"
#include "SparkEditorGlobal.h"

SparkEditorMenuFile::SparkEditorMenuFile()
{
	// New Scene
	wxMenuItem* newMenuItem = new wxMenuItem(this, IDMENU_FILE_NEW, wxT("&New"), wxT("New Scene"), wxITEM_NORMAL);
	wxBitmap newBitmap(SparkEditorGlobal::GetDataPath() + wxT("Data/Icons/16x16/camsave.png") /*wxT("icons/ogscene.png")*/);
	
	newBitmap.SetHeight(16);
	newBitmap.SetWidth(16);

	newMenuItem->SetBitmap(newBitmap);
	this->Append(newMenuItem);
	// Open Scene
	wxMenuItem* openMenuItem = new wxMenuItem(this, IDMENU_FILE_OPEN, wxT("&Open"), wxT("Open Scene"), wxITEM_NORMAL);
	wxBitmap openBitmap(SparkEditorGlobal::GetDataPath() + wxT("icons/fileopen.png"));
	openMenuItem->SetBitmap(openBitmap);
	this->Append(openMenuItem);

	// Save Scene
	wxMenuItem* saveMenuItem = new wxMenuItem(this, IDMENU_FILE_SAVE, wxT("&Save"), wxT("Save Scene"), wxITEM_NORMAL);
	wxBitmap saveBitmap(SparkEditorGlobal::GetDataPath() + wxT("icons/filesave.png"));
	saveMenuItem->SetBitmap(saveBitmap);
	this->Append(saveMenuItem);

	// Save Scene As
	wxMenuItem* saveasMenuItem = new wxMenuItem(this, IDMENU_FILE_SAVEAS, wxT("Save &As"), wxT("Save Scene As"), wxITEM_NORMAL);
	wxBitmap saveasBitmap(SparkEditorGlobal::GetDataPath() + wxT("icons/filesaveas.png"));
	saveasMenuItem->SetBitmap(saveasBitmap);
	this->Append(saveasMenuItem);

	//	Close current scene
	wxMenuItem* closeMenuItem = new wxMenuItem(this, IDMENU_FILE_CLOSE, wxT("Save &As"), wxT("Save Scene As"), wxITEM_NORMAL);
	wxBitmap closeBitmap(SparkEditorGlobal::GetDataPath() + wxT("icons/files.png"));
	closeMenuItem->SetBitmap(closeBitmap);
	this->Append(closeMenuItem);

	// Separator
	this->AppendSeparator();
	// Import / Export
	this->Append(IDMENU_FILE_IMPORT, wxT("Import"), nullptr/*mImportMenu*/);
	this->Append(IDMENU_FILE_EXPORT, wxT("Export"), nullptr/*mExportMenu*/);

	// Separator
	this->AppendSeparator();

	// Scene Settings
	wxMenuItem* recentfileMenuItem = new wxMenuItem(this, IDMENU_FILE_RECENT_FILES, wxT("Scene Settings"), wxT("Scene Settings"), wxITEM_NORMAL);
	wxBitmap recentfileBitmap(SparkEditorGlobal::GetDataPath() + wxT("icons/files.png"));
	recentfileMenuItem->SetBitmap(recentfileBitmap);
	this->Append(recentfileMenuItem);

	// Separator
	this->AppendSeparator();

	// Exit
	wxMenuItem* exitMenuItem = new wxMenuItem(this, IDMENU_FILE_EXIT, wxT("E&xit"), wxT("Exit Application"), wxITEM_NORMAL);
	wxBitmap exitBitmap(SparkEditorGlobal::GetDataPath() + wxT("icons/exit.png"));
	exitMenuItem->SetBitmap(exitBitmap);
	this->Append(exitMenuItem);
}

SparkEditorMenuFile::~SparkEditorMenuFile()
{

}

void SparkEditorMenuFile::ConnectEvent(void)
{
	Connect(IDMENU_FILE_NEW, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileNew));
	Connect(IDMENU_FILE_OPEN, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileOpen));
	Connect(IDMENU_FILE_SAVE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileSave));
	Connect(IDMENU_FILE_SAVEAS, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileSaveAs));
	Connect(IDMENU_FILE_CLOSE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileClose));

	Connect(IDMENU_FILE_IMPORT, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileImport));
	Connect(IDMENU_FILE_EXPORT, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileExport));

	Connect(IDMENU_FILE_RECENT_FILES, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileRecentFiles));
	
	Connect(IDMENU_FILE_EXIT, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(SparkEditorMenuFile::OnFileExit));
}

void SparkEditorMenuFile::OnFileNew(wxCommandEvent& event)
{

}

void SparkEditorMenuFile::OnFileOpen(wxCommandEvent& event)
{

}

void SparkEditorMenuFile::OnFileSave(wxCommandEvent& event)
{

}

void SparkEditorMenuFile::OnFileSaveAs(wxCommandEvent& event)
{

}

void SparkEditorMenuFile::OnFileClose(wxCommandEvent& event)
{

}


void SparkEditorMenuFile::OnFileImport(wxCommandEvent& event)
{

}

void SparkEditorMenuFile::OnFileExport(wxCommandEvent& event)
{

}


void SparkEditorMenuFile::OnFileRecentFiles(wxCommandEvent& event)
{

}


void SparkEditorMenuFile::OnFileExit(wxCommandEvent& event)
{
	// true is to force the frame to close
	GetSparkEditorFrame()->Close(true);
}
